A barcode scanning engine needs to scan a barcode on each frame of image in an input image stream. When the input image stream includes a large number of images of no barcode, a resource of a scanning engine is cost, thereby lowering a velocity of identifying an image of a barcode (for example, a one-dimensional barcode and a two-dimensional barcode).
Currently, a one-dimensional barcode image is roughly identified by using simple image gradient information. A specific process thereof includes: first obtaining an original image, the original image being assumed to be a one-dimensional barcode image, calculating a difference between grayscale values of the original image in an x direction and in a y direction because the one-dimensional barcode image is basically a vertical striped pattern, and an absolute difference between the grayscale values of the one-dimensional barcode image in the x direction and in the y direction is relatively great, then performing fixed threshold binarization on the difference between the grayscale values, thereby filtering out a smooth area, and then performing a mean filtering operation and a morphological operation to identify a one-dimensional barcode area of the original image.
However, a vertical one-dimensional barcode can be identified based on the image gradient information. A one-dimensional barcode that is of slight rotation cannot be identified, other codes besides the one-dimensional barcode also cannot be identified. Therefore, limitations of image identification exist. In addition, a morphological operation and a connected domain analysis are both used to calculate pixels one by one. The amount of the calculation is great, and an object of quickly identifying an image cannot be implemented.